﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net.NetworkInformation;

public partial class NetworkAdapterPage: System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string id = Request.QueryString["id"];
        NetworkAdapter adap = null;

        foreach (NetworkInterface inf in NetworkInterface.GetAllNetworkInterfaces())
        {
            if (inf.Id == id)
            {
                adap = new NetworkAdapter(inf);
                break;
            }
        }

        Title = String.Format("Network adapter: {0}", adap.Name);

        labName.Text = adap.Name;
        labDescription.Text = adap.Description;
        labStatus.Text = adap.Status.ToString();
        labSpeed.Text = adap.Speed.ToString() + "MBs";
        LabIP.Text = adap.IP.ToString();
        labMask.Text = adap.Mask != null ? adap.Mask.ToString() : "<no mask>";
        labDHCP.Text = adap.DHCPServer == null ? "<no dhcp server>" : adap.DHCPServer.ToString();
        labGateway.Text = adap.Gateway == null ? "<no gateway>" : adap.Gateway.ToString();
        labMAC.Text = adap.MACAddress;

        blDNS.DataSource = adap.DNSServers;
        blDNS.DataBind();        
    }
}
